package gretha.panels;

import gretha.GUI.PartieCentrale;
import gretha.donnees.CohorteDuMassif;
import gretha.donnees.Massif;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.util.ArrayList;

import javax.swing.JPanel;

public class CreationScenario extends JPanel {

	private static JPanel corps;

	private PanelListeActions panelListeActions;

	private PanelListeMassifs panelListeMassif;

	private PanelListeCohortes panelListeCohortes;

	private PanelFutur panelFutur;

	private ArrayList<Massif> listeDesMassifsDuScenario;

	private Massif[] listeMassifsTableau;

//	private PanelListeMassifs panelScenario;

//	private PartieCentrale parent;
	
	private CohorteDuMassif[] donnees;


	private static final long serialVersionUID = 1L;

	public CreationScenario(ArrayList<Massif> massifs, PartieCentrale parent) {
		super();
		setLayout(new GridLayout(2, 2));
		setPreferredSize(new Dimension(1024,600));
//		parent = parent;

		// Données
		listeDesMassifsDuScenario = new ArrayList<Massif>();

		// Les Panels
		panelListeActions = new PanelListeActions(this);
		panelListeActions.setBackground(Color.white);

		panelListeMassif = new PanelListeMassifs(this, massifs);
		panelListeMassif.setBackground(Color.white);

		panelListeCohortes = new PanelListeCohortes(this);
		panelListeCohortes.setBackground(Color.white);

		panelFutur = new PanelFutur(this);
		panelFutur.setBackground(Color.white);

		add(panelListeMassif);
		add(panelListeActions);
		add(panelListeCohortes);
		add(panelFutur);
	}

	public void rafraichir() {
		panelListeActions.revalidate();
		panelListeActions.repaint();
		panelListeMassif.revalidate();
		panelListeMassif.repaint();
		panelListeMassif.rafraichir();
		panelListeCohortes.revalidate();
		panelListeCohortes.repaint();
		panelListeCohortes.rafraichir();
		panelFutur.revalidate();
		panelFutur.repaint();
		revalidate();
		repaint();

	}

	public JPanel getCorps() {
		return corps;
	}

	public void setCorps(JPanel corps) {
		CreationScenario.corps = corps;
	}

	public JPanel getHautDePanel() {
		return panelListeActions;
	}

	public void setHautDePanel(PanelListeActions hautDePanel) {
		this.panelListeActions = hautDePanel;
	}

	public ArrayList<Massif> getListeDesMassifsDuScenario() {
		return listeDesMassifsDuScenario;
	}

	public void setListeDesMassifsDuScenario(
			ArrayList<Massif> listeDesMassifsDuScenario) {
		this.listeDesMassifsDuScenario = listeDesMassifsDuScenario;
	}

	public void setListeDesMassifsDuScenario(Massif[] listeDesMassifsDuScenario) {
		if(listeDesMassifsDuScenario.length >0){
		setListeMassifsTableau(listeDesMassifsDuScenario);
		this.listeDesMassifsDuScenario = new ArrayList<Massif>();
		for (Massif m : listeDesMassifsDuScenario) {
			this.listeDesMassifsDuScenario.add(m);
		}
		}
		else{
			setListeMassifsTableau(null);
			this.listeDesMassifsDuScenario = null;
		}

	}

	public Massif[] getListeMassifsTableau() {
		return listeMassifsTableau;
	}

	public void setListeMassifsTableau(Massif[] listeMassifsTableau) {
		this.listeMassifsTableau = listeMassifsTableau;
	}

	public CohorteDuMassif[] getDonnees() {
		return donnees;
	}

	public void setDonnees(CohorteDuMassif[] donnees) {
		this.donnees = donnees;
	}

}
